/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cp2004_assignment2;

import java.util.ArrayList;

/**
 *
 * @author zhaoyingxi JCU Student Number: 11839209
 */
public class ProductArr extends ArrayList<Product> {

    public ProductArr() {       //The Product List
        //Display a list of products
        ItemArr Iitem = new ItemArr();
        Product p = new Product();
        p.setInfo("This is your computer.");
        p.setName("Localhost");
        p.setQuantity(30);
        p.addItem(Iitem.get(0));
        p.addItem(Iitem.get(1));
        add(p);

        p = new Product();
        p.setInfo("This is Jimmy Z. CRT monitor.");
        p.setName("Monitor");
        p.setQuantity(31);
        p.addItem(Iitem.get(0));
        p.addItem(Iitem.get(1));
        add(p);

        p = new Product();
        p.setName("NIC");
        p.setInfo("Network Interface Card on the board.");
        p.setQuantity(33);
        p.addItem(Iitem.get(0));
        p.addItem(Iitem.get(1));
        add(p);

        p = new Product();
        p.setInfo("Using store many data.");
        p.setName("Hard disk");
        p.setQuantity(22);
        p.addItem(Iitem.get(0));
        p.addItem(Iitem.get(1));
        add(p);

        p = new Product();
        p.setInfo("CPU is center of computer,it's very important.");
        p.setName("CPU");
        p.setQuantity(35);
        p.addItem(Iitem.get(0));
        p.addItem(Iitem.get(1));
        add(p);
    }

    @Override
    public String toString() {
        String res = "";
        for (int i = 0; i < size(); i++) {
            Product p = get(i);
            res = res + (i + 1) + ":" + p + "\n";
        }
        return res;
    }
}
